package com.yunmai11.yunmai.adapter;

import android.content.Context;
import android.support.v4.widget.TextViewCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yunmai11.yunmai.R;

import java.util.List;

/**
 * Created by wyz on 2017/1/22.
 */
public class XRecyclerViewAdapter extends RecyclerView.Adapter<XRecyclerViewAdapter.MyViewHolder>{
    private Context mContext;
    private List<String> mDatas;

    public XRecyclerViewAdapter(Context context, List<String> data) {
        this.mContext = context;
        this.mDatas = data;
    }

    @Override
    public XRecyclerViewAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(mContext).inflate(R.layout.xrv_item, parent, false);
        return new MyViewHolder(v);
    }

    @Override
    public void onBindViewHolder(XRecyclerViewAdapter.MyViewHolder holder, int position) {
        holder.tv.setText(mDatas.get(position));
    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder{
        TextView tv;
        public MyViewHolder(View itemView) {
            super(itemView);
            tv = (TextView) itemView.findViewById(R.id.xrv_item_tv);
        }
    }
}
